#!/usr/bin/python
# -*- coding: UTF-8 -*-

from google.appengine.ext import db
from models.HangHoa import HangHoa
from models.LoaiNhanVien import LoaiNhanVien
from models.NhanVien import NhanVien
from models.PhanQuyen import PhanQuyen
from utils.Const import LoaiNhanVien as LoaiNV
import logging
import webapp2


logger = logging.getLogger("CronJob")

class Start(webapp2.RequestHandler):
    def get(self):
        lst = []
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Quản lý'
#        lnv.codeLoaiNV = LoaiNV.QUAN_LY
#        lst.append(lnv)
#        
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Kinh doanh'
#        lnv.codeLoaiNV = LoaiNV.CONG_TAC_VIEN
#        lst.append(lnv)
#        
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Quản lý giao hàng'
#        lnv.codeLoaiNV = LoaiNV.QUAN_LY_GIAO_HANG
#        lst.append(lnv)
#        
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Trưởng ca sản xuất'
#        lnv.codeLoaiNV = LoaiNV.TRUONG_CA_SAN_XUAT
#        lst.append(lnv)
#        
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Kế toán'
#        lnv.codeLoaiNV = LoaiNV.KE_TOAN
#        lst.append(lnv)
#        
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Cộng tác viên'
#        lnv.codeLoaiNV = LoaiNV.CONG_TAC_VIEN
#        lst.append(lnv)
#        
#        lnv = LoaiNhanVien()
#        lnv.tenLoaiNV = u'Trưởng phòng kinh doanh'
#        lnv.codeLoaiNV = LoaiNV.TRUONG_PHONG_KINH_DOANH
#        lst.append(lnv)
#        
#        nv = NhanVien()
#        nv.tenNV = u'Nguyễn Minh Hùng'
#        nv.username = 'nmhung89'
#        lst.append(nv)
        
#        pq = PhanQuyen()
#        pq.maNV = 12
#        pq.func = 'Xuong.HangSanXuatHomNay'
#        pq.menu = 'Xuong'
#        pq.typeId = 2
#        lst.append(pq)

#        pq = PhanQuyen()
#        pq.maNV = 12
#        pq.func = 'QuanLy.PhanQuyen'
#        pq.menu = 'QuanLy'
#        pq.typeId = 2
#        lst.append(pq)
        
#        nv = NhanVien.get_by_id(12)
#        nv.codeLoaiNV = 'TRUONG_CA_SAN_XUAT';
#        nv.save()
        pq = PhanQuyen.get_by_id(15)
        pq.priv = 'Owner'
        
        pq.save()
        pq = PhanQuyen.get_by_id(16)
        pq.priv = 'Owner'
        pq.save()

        db.put(lst)
        
#        lst = []
#        for hh in HangHoa.all():
#            hh.soLuongTonKho = float(hh.soLuongTonKho)
#            lst.append(hh)
#        db.put(lst)
        
        self.response.out.write("App created")